<template>
    <div class="mui-numbox" data-numbox-min='1' data-numbox-max='9'>
		<button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
		<input @change="count(id)" ref="num" id="test" class="mui-input-numbox" type="number" :value="quantity" />
		<button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
	</div>        
</template>
<script>
    import common from "../../../statics/js/common.js";
    import mui from "../../../statics/mui/js/mui.min.js";
    export default{
        props:["max","quantity","id"],
        mounted(){
            mui(".mui-numbox").numbox()
        },
        methods:{
            count(id){
                console.log({
                    id:id,
                    value:this.$refs.num.value
                });
                this.$store.commit("updateGoodsNumber",{
                    id:id,
                    value:this.$refs.num.value
                })
            }
        },
        watch:{
           max:function(newVal,oldVal){
               //设置number_box最大值
               mui(".mui-numbox").numbox().setOption('max',newVal)
           } 
        }
    }
</script>

<style lang="scss" scoped>
    .tmpl{
        padding:0 8px;
        .mui-numbox{
            display: inline-block;
        }
    }
</style>
